#pragma once

#include"RBtreeIterator.h"

template<class K>
class Set
{
	struct SetkeyOfT
	{
		const K& operator()(const K& key)
		{
			return key;
		}
	};

public:
	typedef typename RBTree<K, K, SetkeyOfT>::const_iterator iterator;
	typedef typename RBTree<K, K, SetkeyOfT>::const_iterator const_iterator;

	iterator begin()
	{
		return _t.begin();
	}

	iterator end()
	{
		return _t.end();
	}

	pair<iterator, bool> Insert(const K& key)
	{
		pair<typename RBTree<K, K, SetkeyOfT>::iterator, bool> ret = _t.Insert(key);
		return pair<iterator, bool>(ret.first, ret.second);
	}

private:
	RBTree<K, K, SetkeyOfT> _t;
};

void test_set()
{
	int a[] = { 4, 2, 6, 1, 3, 5, 15, 7, 16, 14 };
	Set<int> s;
	for (auto e : a)
	{
		s.Insert(e);
	}

	Set<int>::iterator it = s.begin();
	while (it != s.end())
	{
		//*it += 10;
		cout << *it << " ";
		++it;
	}
	cout << endl;

	for (auto e : s)
	{
		cout << e << " ";
	}
	cout << endl;
}